package cn.anlab.anappframe.widget.adapter;

import java.util.List;
import java.util.Map;

import cn.anlab.anappframe.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListDialogAdapter extends BaseAdapter {

	private Context context;
	private List<Map<String, String>> dataList;
	LayoutInflater inflater;
	
	public ListDialogAdapter(Context context, List<Map<String, String>> dataList) {
		this.context = context;
		this.dataList = dataList;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return dataList.size();
	}

	@Override
	public Object getItem(int position) {
		return dataList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.demo_listview_item, null);
		}
		Map<String, String> map = (Map<String, String>)getItem(position);
		TextView tv1 = (TextView)convertView.findViewById(R.id.textView1);
		TextView tv2 = (TextView)convertView.findViewById(R.id.textView1);
		TextView tv3 = (TextView)convertView.findViewById(R.id.textView1);
		tv1.setText(map.get("uid"));
		tv2.setText("Age " + map.get("age") + ", High " + map.get("high"));
		tv3.setText(map.get("area"));
		return convertView;
	}

}
